﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Discuz.Toolkit;

namespace Icst.Leaflike.Discuz
{
    public static class UserAccount
    {
        public static bool Login(string userName, string password, out User user)
        {
            user = null;
            try
            {
                DiscuzSession ds = ConformityHandler.InitDiscuzSession();
                int DntUid = ds.GetUserID(ConformityHandler.CreateDiscuzNTUsername(userName));
                ds.Login(DntUid, password, false, 100, "");
                user = ds.GetUserInfo(DntUid);
                return true;
            }
            catch(Exception e)
            {
                return false;
            }
        }
        public static void Logout()
        {
            try
            {
                DiscuzSession ds = ConformityHandler.InitDiscuzSession();
                ds.Logout("");
            }
            catch
            {
            }
        }
    }
}
